<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
  //求1到num的偶数和
  //键盘录入一个num
  let num = prompt("请输入一个整数：")
  //求和
  var number = parseInt(num);
  var sum = 0;
  for (let i = 0; i <= number; i++) {
    if (i % 2 == 0) {
      sum += i;
    }
  }
  alert(sum);
</script>
</body>
</html>